package wortubung.lang.de;

import wortubung.inflection.CONJUGATION;
import wortubung.inflection.ConjugationSet;
import wortubung.inflection.DerivedVerbConjugation;
import wortubung.inflection.VerbConjugation;

public class VorangestelltenVerbKonjugation extends DerivedVerbConjugation {

	private boolean trennbar;

	public VorangestelltenVerbKonjugation(String prefix, boolean separable, VerbConjugation base) {
		super(prefix, base);
		this.trennbar = separable;
	}

	@Override
	protected PrefixProcessor getPrefixProcessor() {
		final PrefixProcessor unzertrennlichPP = new PrefixProcessor() {
			@Override
			protected String toPastParticiple(String prefix, ConjugationSet base) {
				String pastP = base.getPastParticiple();
				if (pastP == null)
					return null;
				if (pastP.startsWith("ge"))
					pastP = pastP.substring(2);
				return prefix + pastP;
			}
		};
		final PrefixProcessor trennbarPP = new PrefixProcessor() {
			@Override
			protected String toConjugation(String prefix, String baseConj, CONJUGATION conjType) {
				if (baseConj == null)
					return null;
				return baseConj + '|' + prefix;
			}
		};

		return trennbar ? trennbarPP : unzertrennlichPP;
	}
}
